package com.gitlab.bootren.test;

import com.gitlab.bootren.data.core.jpa.factory.PlatformJpaRepositoryFactoryBean;
import com.gitlab.bootren.test.entity.TestA;
import com.gitlab.bootren.test.repository.TestARepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

import java.util.List;
import java.util.UUID;

/**
 * Created by serv on 2014/10/15.
 */
@SpringBootApplication
@EnableJpaRepositories(repositoryFactoryBeanClass = PlatformJpaRepositoryFactoryBean.class)
public class Application implements CommandLineRunner{


    @Autowired
    TestARepository repository;


    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }

    @Override
    public void run(String... args) throws Exception {

        TestA a = new TestA();
        a.setAge("sdf");
        a.setName("dsjfdsdd");
        repository.save(a);


        TestA one = repository.findOne("7bc409bee0bc4ea78409bee0bc7ea74c");
        one.setBz("我修改了dfdfdf" + UUID.randomUUID().toString());
        repository.save(one);

        List<TestA> all = repository.findAll();
        System.out.println(all.toString());
    }
}
